
//
//  BK_my_EvaluationOfDryingCell1.m
//  bestkeep
//
//  Created by 李明 on 2016/11/30.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BK_my_EvaluationOfDryingCell1.h"
#import "Masonry.h"
#import "BKMyCommon.h"
#import "CacheImage.h"

@implementation BK_my_EvaluationOfDryingCell1

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)initializeCell:(CellModel *)cellModel {
    self.delegate = cellModel.delegate;
    [_goodsIcon load:cellModel.image];
    _goodsLabel.text = cellModel.title;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor whiteColor];
        _goodsIcon = [[UIImageView alloc] init];
        _goodsIcon.layer.borderColor = RGBCOLOR(221, 221, 221, 1).CGColor;
        _goodsIcon.clipsToBounds = YES;
        _goodsIcon.layer.borderWidth = .5f;
        _goodsIcon.layer.cornerRadius = 3;
        [self.contentView addSubview:_goodsIcon];
        [_goodsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(20);
            
            make.left.mas_equalTo(self.contentView.mas_left).offset(ApplicationBackGauge);
            make.width.mas_equalTo(60);
            make.width.mas_equalTo(_goodsIcon.mas_height).multipliedBy(1);
        }];
        
        _goodsLabel = [[UILabel alloc] init];
        _goodsLabel.text = @"";
        _goodsLabel.textColor = [UIColor colorWithRed:68 / 255 green:68 / 255 blue:68 / 255 alpha:1.0];
        _goodsLabel.font = [UIFont systemFontOfSize:14.0];
        _goodsLabel.numberOfLines = 2;
        [self.contentView addSubview:_goodsLabel];
        [_goodsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-ApplicationBackGauge);
            make.left.mas_equalTo(_goodsIcon.mas_right).offset(10);
        }];
        
        BK_my_EvluationStarRateView *starView = [[BK_my_EvluationStarRateView alloc] initWithFrame:CGRectMake(20, 60, 150, 40)];
        starView.isAnimation = YES;
        starView.rateStyle = WholeStar;
        starView.delegate = self;
        [starView setCurrentScore:5];
        [self.contentView addSubview:starView];
        [starView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_goodsIcon.mas_right).offset(10);
            make.bottom.mas_equalTo(_goodsIcon.mas_bottom);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(150);
        }];
    }
    return self;
}

- (void)starRateView:(BK_my_EvluationStarRateView *)starRateView currentScore:(CGFloat)currentScore {
    NSNotification *notice = [NSNotification notificationWithName:@"currentScore" object:nil userInfo:@{@"starCount":[NSString stringWithFormat:@"%0.f",currentScore]}];
    [[NSNotificationCenter defaultCenter] postNotification:notice];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
